﻿using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a template for gray value matching.</summary>
	// Token: 0x0200006A RID: 106
	[Serializable]
	public class HTemplate : HHandle, ISerializable, ICloneable
	{
		// Token: 0x060018CD RID: 6349 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HTemplate() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x060018CE RID: 6350 RVA: 0x0009E654 File Offset: 0x0009C854
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HTemplate(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060018CF RID: 6351 RVA: 0x0009E663 File Offset: 0x0009C863
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HTemplate(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060018D0 RID: 6352 RVA: 0x0009E672 File Offset: 0x0009C872
		private void AssertSemType()
		{
			base.AssertSemType("template");
		}

		// Token: 0x060018D1 RID: 6353 RVA: 0x0009E67F File Offset: 0x0009C87F
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HTemplate obj)
		{
			obj = new HTemplate(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x060018D2 RID: 6354 RVA: 0x0009E698 File Offset: 0x0009C898
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HTemplate[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HTemplate[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HTemplate(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Preparing a pattern for template matching with rotation.
		///   Modified instance represents: Template number.
		/// </summary>
		/// <param name="template">Input image whose domain will be processed for the pattern matching.</param>
		/// <param name="numLevel">Maximal number of pyramid levels. Default: 4</param>
		/// <param name="angleStart">Smallest Rotation of the pattern. Default: -0.39</param>
		/// <param name="angleExtend">Maximum positive Extension of AngleStart. Default: 0.79</param>
		/// <param name="angleStep">Step rate (angle precision) of matching. Default: 0.0982</param>
		/// <param name="optimize">Kind of optimizing. Default: "sort"</param>
		/// <param name="grayValues">Kind of grayvalues. Default: "original"</param>
		// Token: 0x060018D3 RID: 6355 RVA: 0x0009E708 File Offset: 0x0009C908
		public HTemplate(HImage template, int numLevel, double angleStart, double angleExtend, double angleStep, string optimize, string grayValues)
		{
			IntPtr proc = HalconAPI.PreCall(1488);
			HalconAPI.Store(proc, 1, template);
			HalconAPI.StoreI(proc, 0, numLevel);
			HalconAPI.StoreD(proc, 1, angleStart);
			HalconAPI.StoreD(proc, 2, angleExtend);
			HalconAPI.StoreD(proc, 3, angleStep);
			HalconAPI.StoreS(proc, 4, optimize);
			HalconAPI.StoreS(proc, 5, grayValues);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(template);
		}

		/// <summary>
		///   Preparing a pattern for template matching.
		///   Modified instance represents: Template number.
		/// </summary>
		/// <param name="template">Input image whose domain will be processed for the pattern matching.</param>
		/// <param name="firstError">Not yet in use. Default: 255</param>
		/// <param name="numLevel">Maximal number of pyramid levels. Default: 4</param>
		/// <param name="optimize">Kind of optimizing. Default: "sort"</param>
		/// <param name="grayValues">Kind of grayvalues. Default: "original"</param>
		// Token: 0x060018D4 RID: 6356 RVA: 0x0009E790 File Offset: 0x0009C990
		public HTemplate(HImage template, int firstError, int numLevel, string optimize, string grayValues)
		{
			IntPtr proc = HalconAPI.PreCall(1489);
			HalconAPI.Store(proc, 1, template);
			HalconAPI.StoreI(proc, 0, firstError);
			HalconAPI.StoreI(proc, 1, numLevel);
			HalconAPI.StoreS(proc, 2, optimize);
			HalconAPI.StoreS(proc, 3, grayValues);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(template);
		}

		/// <summary>
		///   Reading a template from file.
		///   Modified instance represents: Template number.
		/// </summary>
		/// <param name="fileName">file name.</param>
		// Token: 0x060018D5 RID: 6357 RVA: 0x0009E804 File Offset: 0x0009CA04
		public HTemplate(string fileName)
		{
			IntPtr proc = HalconAPI.PreCall(1493);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		// Token: 0x060018D6 RID: 6358 RVA: 0x0009E850 File Offset: 0x0009CA50
		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = this.SerializeTemplate();
			byte[] value = hserializedItem;
			hserializedItem.Dispose();
			info.AddValue("data", value, typeof(byte[]));
		}

		// Token: 0x060018D7 RID: 6359 RVA: 0x0009E888 File Offset: 0x0009CA88
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HTemplate(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = new HSerializedItem((byte[])info.GetValue("data", typeof(byte[])));
			this.DeserializeTemplate(hserializedItem);
			hserializedItem.Dispose();
		}

		/// <summary>Serialize object to binary stream in HALCON format</summary>
		// Token: 0x060018D8 RID: 6360 RVA: 0x0009E8C8 File Offset: 0x0009CAC8
		public new void Serialize(Stream stream)
		{
			HSerializedItem hserializedItem = this.SerializeTemplate();
			hserializedItem.Serialize(stream);
			hserializedItem.Dispose();
		}

		/// <summary>Deserialize object from binary stream in HALCON format</summary>
		// Token: 0x060018D9 RID: 6361 RVA: 0x0009E8DC File Offset: 0x0009CADC
		public new static HTemplate Deserialize(Stream stream)
		{
			HTemplate htemplate = new HTemplate();
			HSerializedItem hserializedItem = HSerializedItem.Deserialize(stream);
			htemplate.DeserializeTemplate(hserializedItem);
			hserializedItem.Dispose();
			return htemplate;
		}

		// Token: 0x060018DA RID: 6362 RVA: 0x0009E902 File Offset: 0x0009CB02
		object ICloneable.Clone()
		{
			return this.Clone();
		}

		// Token: 0x060018DB RID: 6363 RVA: 0x0009E90C File Offset: 0x0009CB0C
		public new HTemplate Clone()
		{
			HSerializedItem hserializedItem = this.SerializeTemplate();
			HTemplate htemplate = new HTemplate();
			htemplate.DeserializeTemplate(hserializedItem);
			hserializedItem.Dispose();
			return htemplate;
		}

		/// <summary>
		///   Preparing a pattern for template matching with rotation.
		///   Modified instance represents: Template number.
		/// </summary>
		/// <param name="template">Input image whose domain will be processed for the pattern matching.</param>
		/// <param name="numLevel">Maximal number of pyramid levels. Default: 4</param>
		/// <param name="angleStart">Smallest Rotation of the pattern. Default: -0.39</param>
		/// <param name="angleExtend">Maximum positive Extension of AngleStart. Default: 0.79</param>
		/// <param name="angleStep">Step rate (angle precision) of matching. Default: 0.0982</param>
		/// <param name="optimize">Kind of optimizing. Default: "sort"</param>
		/// <param name="grayValues">Kind of grayvalues. Default: "original"</param>
		// Token: 0x060018DC RID: 6364 RVA: 0x0009E934 File Offset: 0x0009CB34
		public void CreateTemplateRot(HImage template, int numLevel, double angleStart, double angleExtend, double angleStep, string optimize, string grayValues)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1488);
			HalconAPI.Store(proc, 1, template);
			HalconAPI.StoreI(proc, 0, numLevel);
			HalconAPI.StoreD(proc, 1, angleStart);
			HalconAPI.StoreD(proc, 2, angleExtend);
			HalconAPI.StoreD(proc, 3, angleStep);
			HalconAPI.StoreS(proc, 4, optimize);
			HalconAPI.StoreS(proc, 5, grayValues);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(template);
		}

		/// <summary>
		///   Preparing a pattern for template matching.
		///   Modified instance represents: Template number.
		/// </summary>
		/// <param name="template">Input image whose domain will be processed for the pattern matching.</param>
		/// <param name="firstError">Not yet in use. Default: 255</param>
		/// <param name="numLevel">Maximal number of pyramid levels. Default: 4</param>
		/// <param name="optimize">Kind of optimizing. Default: "sort"</param>
		/// <param name="grayValues">Kind of grayvalues. Default: "original"</param>
		// Token: 0x060018DD RID: 6365 RVA: 0x0009E9BC File Offset: 0x0009CBBC
		public void CreateTemplate(HImage template, int firstError, int numLevel, string optimize, string grayValues)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1489);
			HalconAPI.Store(proc, 1, template);
			HalconAPI.StoreI(proc, 0, firstError);
			HalconAPI.StoreI(proc, 1, numLevel);
			HalconAPI.StoreS(proc, 2, optimize);
			HalconAPI.StoreS(proc, 3, grayValues);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(template);
		}

		/// <summary>
		///   Serialize a template.
		///   Instance represents: Handle of the template.
		/// </summary>
		/// <returns>Handle of the serialized item.</returns>
		// Token: 0x060018DE RID: 6366 RVA: 0x0009EA30 File Offset: 0x0009CC30
		public HSerializedItem SerializeTemplate()
		{
			IntPtr proc = HalconAPI.PreCall(1490);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HSerializedItem result;
			num = HSerializedItem.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Deserialize a serialized template.
		///   Modified instance represents: Template number.
		/// </summary>
		/// <param name="serializedItemHandle">Handle of the serialized item.</param>
		// Token: 0x060018DF RID: 6367 RVA: 0x0009EA78 File Offset: 0x0009CC78
		public void DeserializeTemplate(HSerializedItem serializedItemHandle)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1491);
			HalconAPI.Store(proc, 0, serializedItemHandle);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(serializedItemHandle);
		}

		/// <summary>
		///   Writing a template to file.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="fileName">file name.</param>
		// Token: 0x060018E0 RID: 6368 RVA: 0x0009EACC File Offset: 0x0009CCCC
		public void WriteTemplate(string fileName)
		{
			IntPtr proc = HalconAPI.PreCall(1492);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, fileName);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Reading a template from file.
		///   Modified instance represents: Template number.
		/// </summary>
		/// <param name="fileName">file name.</param>
		// Token: 0x060018E1 RID: 6369 RVA: 0x0009EB08 File Offset: 0x0009CD08
		public void ReadTemplate(string fileName)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1493);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Deallocation of the memory of a template.
		///   Instance represents: Template number.
		/// </summary>
		// Token: 0x060018E2 RID: 6370 RVA: 0x0009EB54 File Offset: 0x0009CD54
		public void ClearTemplate()
		{
			IntPtr proc = HalconAPI.PreCall(1495);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Gray value offset for template.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="grayOffset">Offset of gray values. Default: 0</param>
		// Token: 0x060018E3 RID: 6371 RVA: 0x0009EB88 File Offset: 0x0009CD88
		public void SetOffsetTemplate(int grayOffset)
		{
			IntPtr proc = HalconAPI.PreCall(1496);
			base.Store(proc, 0);
			HalconAPI.StoreI(proc, 1, grayOffset);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Define reference position for a matching template.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="row">Reference position of template (row).</param>
		/// <param name="column">Reference position of template (column).</param>
		// Token: 0x060018E4 RID: 6372 RVA: 0x0009EBC4 File Offset: 0x0009CDC4
		public void SetReferenceTemplate(double row, double column)
		{
			IntPtr proc = HalconAPI.PreCall(1497);
			base.Store(proc, 0);
			HalconAPI.StoreD(proc, 1, row);
			HalconAPI.StoreD(proc, 2, column);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Adapting a template to the size of an image.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Image which determines the size of the later matching.</param>
		// Token: 0x060018E5 RID: 6373 RVA: 0x0009EC08 File Offset: 0x0009CE08
		public void AdaptTemplate(HImage image)
		{
			IntPtr proc = HalconAPI.PreCall(1498);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Searching all good gray value matches in a pyramid.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximal average difference of the grayvalues. Default: 30.0</param>
		/// <param name="numLevel">Number of levels in the pyramid. Default: 3</param>
		/// <returns>All points which have an error below a certain threshold.</returns>
		// Token: 0x060018E6 RID: 6374 RVA: 0x0009EC4C File Offset: 0x0009CE4C
		public HRegion FastMatchMg(HImage image, double maxError, HTuple numLevel)
		{
			IntPtr proc = HalconAPI.PreCall(1499);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.Store(proc, 2, numLevel);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(numLevel);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
			return result;
		}

		/// <summary>
		///   Searching all good gray value matches in a pyramid.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximal average difference of the grayvalues. Default: 30.0</param>
		/// <param name="numLevel">Number of levels in the pyramid. Default: 3</param>
		/// <returns>All points which have an error below a certain threshold.</returns>
		// Token: 0x060018E7 RID: 6375 RVA: 0x0009ECB8 File Offset: 0x0009CEB8
		public HRegion FastMatchMg(HImage image, double maxError, int numLevel)
		{
			IntPtr proc = HalconAPI.PreCall(1499);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.StoreI(proc, 2, numLevel);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
			return result;
		}

		/// <summary>
		///   Searching the best gray value matches in a pre generated pyramid.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="imagePyramid">Image pyramid inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximal average difference of the grayvalues. Default: 30.0</param>
		/// <param name="subPixel">Exactness in subpixels in case of 'true'. Default: "false"</param>
		/// <param name="numLevels">Number of the used resolution levels. Default: 3</param>
		/// <param name="whichLevels">Resolution level up to which the method "best match" is used. Default: "original"</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="error">Average divergence of the grayvalues in the best match.</param>
		// Token: 0x060018E8 RID: 6376 RVA: 0x0009ED20 File Offset: 0x0009CF20
		public void BestMatchPreMg(HImage imagePyramid, double maxError, string subPixel, int numLevels, HTuple whichLevels, out double row, out double column, out double error)
		{
			IntPtr proc = HalconAPI.PreCall(1500);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, imagePyramid);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.StoreS(proc, 2, subPixel);
			HalconAPI.StoreI(proc, 3, numLevels);
			HalconAPI.Store(proc, 4, whichLevels);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(whichLevels);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(imagePyramid);
		}

		/// <summary>
		///   Searching the best gray value matches in a pre generated pyramid.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="imagePyramid">Image pyramid inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximal average difference of the grayvalues. Default: 30.0</param>
		/// <param name="subPixel">Exactness in subpixels in case of 'true'. Default: "false"</param>
		/// <param name="numLevels">Number of the used resolution levels. Default: 3</param>
		/// <param name="whichLevels">Resolution level up to which the method "best match" is used. Default: "original"</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="error">Average divergence of the grayvalues in the best match.</param>
		// Token: 0x060018E9 RID: 6377 RVA: 0x0009EDC4 File Offset: 0x0009CFC4
		public void BestMatchPreMg(HImage imagePyramid, double maxError, string subPixel, int numLevels, int whichLevels, out double row, out double column, out double error)
		{
			IntPtr proc = HalconAPI.PreCall(1500);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, imagePyramid);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.StoreS(proc, 2, subPixel);
			HalconAPI.StoreI(proc, 3, numLevels);
			HalconAPI.StoreI(proc, 4, whichLevels);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			int num = HalconAPI.CallProcedure(proc);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(imagePyramid);
		}

		/// <summary>
		///   Searching the best gray value matches in a pyramid.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximal average difference of the grayvalues. Default: 30.0</param>
		/// <param name="subPixel">Exactness in subpixels in case of 'true'. Default: "false"</param>
		/// <param name="numLevels">Number of the used resolution levels. Default: 4</param>
		/// <param name="whichLevels">Resolution level up to which the method "best match" is used. Default: 2</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="error">Average divergence of the grayvalues in the best match.</param>
		// Token: 0x060018EA RID: 6378 RVA: 0x0009EE64 File Offset: 0x0009D064
		public void BestMatchMg(HImage image, double maxError, string subPixel, int numLevels, HTuple whichLevels, out double row, out double column, out double error)
		{
			IntPtr proc = HalconAPI.PreCall(1501);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.StoreS(proc, 2, subPixel);
			HalconAPI.StoreI(proc, 3, numLevels);
			HalconAPI.Store(proc, 4, whichLevels);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(whichLevels);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Searching the best gray value matches in a pyramid.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximal average difference of the grayvalues. Default: 30.0</param>
		/// <param name="subPixel">Exactness in subpixels in case of 'true'. Default: "false"</param>
		/// <param name="numLevels">Number of the used resolution levels. Default: 4</param>
		/// <param name="whichLevels">Resolution level up to which the method "best match" is used. Default: 2</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="error">Average divergence of the grayvalues in the best match.</param>
		// Token: 0x060018EB RID: 6379 RVA: 0x0009EF08 File Offset: 0x0009D108
		public void BestMatchMg(HImage image, double maxError, string subPixel, int numLevels, int whichLevels, out double row, out double column, out double error)
		{
			IntPtr proc = HalconAPI.PreCall(1501);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.StoreS(proc, 2, subPixel);
			HalconAPI.StoreI(proc, 3, numLevels);
			HalconAPI.StoreI(proc, 4, whichLevels);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			int num = HalconAPI.CallProcedure(proc);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Searching all good matches of a template and an image.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximal average difference of the grayvalues. Default: 20.0</param>
		/// <returns>All points whose error lies below a certain threshold.</returns>
		// Token: 0x060018EC RID: 6380 RVA: 0x0009EFA8 File Offset: 0x0009D1A8
		public HRegion FastMatch(HImage image, double maxError)
		{
			IntPtr proc = HalconAPI.PreCall(1502);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
			return result;
		}

		/// <summary>
		///   Searching the best matching of a template and a pyramid with rotation.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="angleStart">Smallest Rotation of the pattern. Default: -0.39</param>
		/// <param name="angleExtend">Maximum positive Extension of AngleStart. Default: 0.79</param>
		/// <param name="maxError">Maximum average difference of the grayvalues. Default: 40.0</param>
		/// <param name="subPixel">Subpixel accuracy in case of 'true'. Default: "false"</param>
		/// <param name="numLevels">Number of the used resolution levels. Default: 3</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="angle">Rotation angle of pattern.</param>
		/// <param name="error">Average divergence of the grayvalues of the best match.</param>
		// Token: 0x060018ED RID: 6381 RVA: 0x0009F008 File Offset: 0x0009D208
		public void BestMatchRotMg(HImage image, double angleStart, double angleExtend, double maxError, string subPixel, int numLevels, out HTuple row, out HTuple column, out HTuple angle, out HTuple error)
		{
			IntPtr proc = HalconAPI.PreCall(1503);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, angleStart);
			HalconAPI.StoreD(proc, 2, angleExtend);
			HalconAPI.StoreD(proc, 3, maxError);
			HalconAPI.StoreS(proc, 4, subPixel);
			HalconAPI.StoreI(proc, 5, numLevels);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			int num = HalconAPI.CallProcedure(proc);
			num = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, num, out row);
			num = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, num, out column);
			num = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, num, out angle);
			num = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Searching the best matching of a template and a pyramid with rotation.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="angleStart">Smallest Rotation of the pattern. Default: -0.39</param>
		/// <param name="angleExtend">Maximum positive Extension of AngleStart. Default: 0.79</param>
		/// <param name="maxError">Maximum average difference of the grayvalues. Default: 40.0</param>
		/// <param name="subPixel">Subpixel accuracy in case of 'true'. Default: "false"</param>
		/// <param name="numLevels">Number of the used resolution levels. Default: 3</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="angle">Rotation angle of pattern.</param>
		/// <param name="error">Average divergence of the grayvalues of the best match.</param>
		// Token: 0x060018EE RID: 6382 RVA: 0x0009F0C8 File Offset: 0x0009D2C8
		public void BestMatchRotMg(HImage image, double angleStart, double angleExtend, double maxError, string subPixel, int numLevels, out double row, out double column, out double angle, out double error)
		{
			IntPtr proc = HalconAPI.PreCall(1503);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, angleStart);
			HalconAPI.StoreD(proc, 2, angleExtend);
			HalconAPI.StoreD(proc, 3, maxError);
			HalconAPI.StoreS(proc, 4, subPixel);
			HalconAPI.StoreI(proc, 5, numLevels);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			int num = HalconAPI.CallProcedure(proc);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out angle);
			num = HalconAPI.LoadD(proc, 3, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Searching the best matching of a template and an image with rotation.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="angleStart">Smallest Rotation of the pattern. Default: -0.39</param>
		/// <param name="angleExtend">Maximum positive Extension of AngleStart. Default: 0.79</param>
		/// <param name="maxError">Maximum average difference of the grayvalues. Default: 30.0</param>
		/// <param name="subPixel">Subpixel accuracy in case of 'true'. Default: "false"</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="angle">Rotation angle of pattern.</param>
		/// <param name="error">Average divergence of the grayvalues of the best match.</param>
		// Token: 0x060018EF RID: 6383 RVA: 0x0009F184 File Offset: 0x0009D384
		public void BestMatchRot(HImage image, double angleStart, double angleExtend, double maxError, string subPixel, out HTuple row, out HTuple column, out HTuple angle, out HTuple error)
		{
			IntPtr proc = HalconAPI.PreCall(1504);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, angleStart);
			HalconAPI.StoreD(proc, 2, angleExtend);
			HalconAPI.StoreD(proc, 3, maxError);
			HalconAPI.StoreS(proc, 4, subPixel);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			int num = HalconAPI.CallProcedure(proc);
			num = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, num, out row);
			num = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, num, out column);
			num = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, num, out angle);
			num = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Searching the best matching of a template and an image with rotation.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="angleStart">Smallest Rotation of the pattern. Default: -0.39</param>
		/// <param name="angleExtend">Maximum positive Extension of AngleStart. Default: 0.79</param>
		/// <param name="maxError">Maximum average difference of the grayvalues. Default: 30.0</param>
		/// <param name="subPixel">Subpixel accuracy in case of 'true'. Default: "false"</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="angle">Rotation angle of pattern.</param>
		/// <param name="error">Average divergence of the grayvalues of the best match.</param>
		// Token: 0x060018F0 RID: 6384 RVA: 0x0009F238 File Offset: 0x0009D438
		public void BestMatchRot(HImage image, double angleStart, double angleExtend, double maxError, string subPixel, out double row, out double column, out double angle, out double error)
		{
			IntPtr proc = HalconAPI.PreCall(1504);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, angleStart);
			HalconAPI.StoreD(proc, 2, angleExtend);
			HalconAPI.StoreD(proc, 3, maxError);
			HalconAPI.StoreS(proc, 4, subPixel);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			int num = HalconAPI.CallProcedure(proc);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out angle);
			num = HalconAPI.LoadD(proc, 3, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Searching the best matching of a template and an image.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximum average difference of the grayvalues. Default: 20.0</param>
		/// <param name="subPixel">Subpixel accuracy in case of 'true'. Default: "false"</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="error">Average divergence of the grayvalues of the best match.</param>
		// Token: 0x060018F1 RID: 6385 RVA: 0x0009F2E8 File Offset: 0x0009D4E8
		public void BestMatch(HImage image, double maxError, string subPixel, out HTuple row, out HTuple column, out HTuple error)
		{
			IntPtr proc = HalconAPI.PreCall(1505);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.StoreS(proc, 2, subPixel);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			int num = HalconAPI.CallProcedure(proc);
			num = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, num, out row);
			num = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, num, out column);
			num = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Searching the best matching of a template and an image.
		///   Instance represents: Template number.
		/// </summary>
		/// <param name="image">Input image inside of which the pattern has to be found.</param>
		/// <param name="maxError">Maximum average difference of the grayvalues. Default: 20.0</param>
		/// <param name="subPixel">Subpixel accuracy in case of 'true'. Default: "false"</param>
		/// <param name="row">Row position of the best match.</param>
		/// <param name="column">Column position of the best match.</param>
		/// <param name="error">Average divergence of the grayvalues of the best match.</param>
		// Token: 0x060018F2 RID: 6386 RVA: 0x0009F378 File Offset: 0x0009D578
		public void BestMatch(HImage image, double maxError, string subPixel, out double row, out double column, out double error)
		{
			IntPtr proc = HalconAPI.PreCall(1505);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreD(proc, 1, maxError);
			HalconAPI.StoreS(proc, 2, subPixel);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			int num = HalconAPI.CallProcedure(proc);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out error);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}
	}
}
